package com.botarena.client.account;

import com.botarena.shared.UserInfo;
import com.google.gwt.user.client.ui.Panel;

/**
 * GUI do edycji konta uzytkownika
 * 
 * @author quermit
 * 
 */
public class AccountEditor {

	public static Panel createRegistrationForm(UserInfo userInfo) {	
		AccountEditorPanelWidget accountEditor = new AccountEditorPanelWidget("/servlet/http/updateAccount");
		
		accountEditor.setAccountName(userInfo.getNickname());
		accountEditor.setEmail(userInfo.getEmailAddress());

		return accountEditor.getPanel();
	}
	
	public static Panel createEditForm(UserInfo userInfo) {	
		AccountEditorPanelWidget accountEditor = new AccountEditorPanelWidget("/servlet/http/updateAccount");
		
		accountEditor.setKey(userInfo.getKey());
		accountEditor.setAccountName(userInfo.getNickname());
		accountEditor.setEmail(userInfo.getEmailAddress());
		accountEditor.setName(userInfo.getName());
		if (userInfo.hasAvatar())
			accountEditor.setAvatar(userInfo.getAvatarUrl());
		
		return accountEditor.getPanel();
	}

}
